const express = require('express');
const app = express();
const path = require('path');
const router = require('./router/router').router;
const session = require('express-session');
const bodyParser = require('body-parser');
const ejsFun = require('./utils/ejsFun');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
//设置模板引擎
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(ejsFun);
app.use(express.static(path.join(__dirname, 'public')));
//配置中间件
app.use(session({
    secret: "check demo",
    resave: false,
    saveUninitialized: true,
    cookie: ({
        maxAge:  60*60*1000,
        httpOnly: true
    })
}));
router(app);
module.exports = app;